home *** CD-ROM | disk | FTP | other *** search
- class pi.Hashtable
- {
- var table;
- var keys;
- var vals;
- function Hashtable()
- {
- this.clear();
- }
- function addItem(key, val)
- {
- this.table[key] = val;
- this.keys.push(key);
- this.vals.push(val);
- }
- function removeItem(key)
- {
- var _loc2_ = 0;
- while(_loc2_ < this.keys.length)
- {
- if(this.keys[_loc2_] == key)
- {
- this.keys.splice(_loc2_,1);
- this.vals.splice(_loc2_,1);
- break;
- }
- _loc2_ = _loc2_ + 1;
- }
- }
- function getItem(key)
- {
- return this.table[key];
- }
- function clear()
- {
- this.table = new Array();
- this.keys = new Array();
- this.vals = new Array();
- }
- function duplicate()
- {
- var _loc3_ = new pi.Hashtable();
- var _loc2_ = 0;
- while(_loc2_ < this.keys.length)
- {
- _loc3_.addItem(this.keys[_loc2_],this.vals[_loc2_]);
- _loc2_ = _loc2_ + 1;
- }
- return _loc3_;
- }
- function containsKey(key)
- {
- var _loc2_ = 0;
- while(_loc2_ < this.keys.length)
- {
- if(this.keys[_loc2_] == key)
- {
- return true;
- }
- _loc2_ = _loc2_ + 1;
- }
- return false;
- }
- function containsValue(val)
- {
- var _loc2_ = 0;
- while(_loc2_ < this.vals.length)
- {
- if(this.vals[_loc2_] == val)
- {
- return true;
- }
- _loc2_ = _loc2_ + 1;
- }
- return false;
- }
- }
-